<template>
  <el-dialog
      :model-value="dialogVisible"
      :title="props.dialogStTitle"
      width="40%"
      @close="handleClose"
  >
    <el-form :model="form" ref="formRef" label-width="140px" :rules="rules">
      <el-form-item label="仓库名称" prop="storageName">
        <el-input v-model="form.storageName" clearable/>
      </el-form-item>
      <el-form-item label="仓库负责人" prop="storageFzr">
        <el-input v-model="form.storageFzr" clearable/>
      </el-form-item>
      <el-form-item label="仓库容量" prop="storageRl">
        <el-input v-model="form.storageRl" clearable/>
      </el-form-item>
      <el-form-item label="仓库地址" prop="storageAddr">
        <el-input v-model="form.storageAddr" />
      </el-form-item>
      <el-form-item label="仓库联系人电话" prop="storageDh">
        <el-input v-model="form.storageDh" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="handleConfirm">
          确认
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import {defineEmits, ref, defineProps, watch, onMounted} from 'vue'

const props = defineProps({
  dialogStTitle: {
    type: String,
    default: '',
    required: true
  },
  dialogStTableValue: {
    type: Object,
    default: {}
  },
  queryForm: {
  },
  dialogVisible: {
    type: Boolean,
    default: false
  }
})

const formRef = ref(null)
const form = ref({
  storageName: '',
  storageFzr: '',
  storageRl: '',
  storageAddr: '',
  storageDh: '',
  cjsj: ''
})
const rules = ref({
  storageFzr: [{
    required: true,
    message: '不能为空',
    trigger: ['blur', 'change'],
  }],
  storageDh: [{
    required: true,
    message: '不能为空',
    trigger: ['blur', 'change'],
  }],
  storageName: [{
    required: true,
    message: '不能为空',
    trigger: ['blur', 'change'],
  }],
  storageRl: [{
    required: true,
    message: '不能为空',
    trigger: ['blur', 'change'],
  }],
  storageAddr: [{
    required: true,
    message: '不能为空',
    trigger: ['blur', 'change'],
  }],
})
onMounted(()=> {
  form.value = props.dialogStTableValue
})

const emits = defineEmits(['update:modelValue', 'handleConfirm'])
const handleClose = ()=> {
  emits('update:modelValue', false)
}
const handleConfirm = () => {
  emits("handleConfirm", {...form.value}, {...formRef.value})
}
</script>

<style scoped>


</style>